03 / 03

What is the target="_blank" attribute used for?

Role of the target="_blank" Attribute in <a>

The target="_blank" attribute in the <a> (anchor) tag is used to open the linked document in a new browser tab or window. This allows users to view the new page without leaving the current one.

Key Points about target="_blank"
  1. 1

    It tells the browser to open the hyperlink in a new tab or window.

  2. 2

    Useful for keeping the current page open while navigating to external sites.

  3. 3

    Should be used carefully, as too many new tabs can annoy users.

  4. 4

    For security, it’s best practice to also add rel="noopener noreferrer" when using target="_blank".

Example Usage

In short: target="_blank" makes a link open in a new tab or window, often combined with rel="noopener noreferrer" for security.

Difficulty: 4/10
Topics: link behavior, security, accessibility

Scenario Questions

0-2 years experience
  1. 1

    You need to add a link to an external article that should open in a new tab. How would you write the HTML?

  2. 2

    If you forget to include target="_blank" on that link, what will the user experience be?

  3. 3

    What attribute would you add to make sure the new tab can't access the original page's window object?

2-5 years experience
  1. 1

    A bug report says that links with target="_blank" are sometimes opening in the same tab after a recent JavaScript refactor. How would you investigate and fix it?

  2. 2

    Explain the trade‑offs between using target="_blank" for external links versus handling navigation through your SPA router.

  3. 3

    Your design system requires all external links to open in a new tab but also to be safe from reverse tabnabbing. How would you implement that in the component?

5-8 years experience
  1. 1

    You are building a reusable Link component used across dozens of services. Describe how you would enforce security best practices while keeping the API simple.

  2. 2

    Discuss the performance and SEO implications of using target="_blank" at scale, and how you would monitor any negative impact.

  3. 3

    How would you design a lint rule or CI check to prevent missing rel attributes on target="_blank" links in a large codebase?

8+ years experience
  1. 1

    Your organization is migrating legacy HTML pages to a component library. What strategy would you use to replace inline target="_blank" links with a standardized, secure approach without breaking existing analytics?

  2. 2

    Across multiple product teams, there is disagreement about opening external links in new tabs. How would you lead a cross‑team policy decision, considering accessibility, security, and user experience?

Follow-up Questions

  • What security concerns arise from using target="_blank"?
  • How would you prevent reverse tabnabbing in your implementation?
  • Can you describe a situation where you would deliberately avoid using target="_blank"?